package student_System;

import java.util.Random;

public class test {
    public static void main(String[] args) {
        System.out.println(getCode());
    }
    //获取验证码
    private static String getCode() {
        Random r =  new Random();
        StringBuffer sb = new StringBuffer();
        //创建一个数组
        char[] arr = new char[52];
        for (int i = 0; i < arr.length; i++) {
            if ( i <= 25){
                arr[i] = (char)('a' + i);
                arr[i+26] = (char)('A' + i);
            }
        }
        for (int i = 0; i < 4; i++) {
            int index = r.nextInt(52);
            sb.append(arr[index]);
        }
        sb.append(r.nextInt(10));
        String sb1 = sb.toString();
        char[] arrsb = sb1.toCharArray();
        int index = r.nextInt(5);
        char temp1 = arrsb[index];
        char temp2 = arrsb[arrsb.length - 1 ];
        arrsb[index] = temp2;
        arrsb[arrsb.length - 1] = temp1;

        return new String(arrsb);
    }
}
